#include "ui.h"

/***********************新ui相关定义*****************************/
//ui偏移
#define Sheet_x 36
#define Sheet_y 80

//柱状图像素上限
#define Show_MAX 120

/***************************************************************/

struct RUN_TIME
{
    uint16_t h;
    uint8_t m;
    uint8_t s;
};

extern uint8_t P_Complete;
extern uint8_t NodeState[11];
extern uint16_t PowerSetValue;
extern int ACT_Count;
extern struct RUN_TIME RunTime;

char* Err_Str;      //错误信息字符串指针
char* Time_Str;     //运行时间字符串指针

//RGB888转RGB565格式
uint16_t RGB888ToRGB565(uint32_t color) {
    uint8_t r = (color >> 16) & 0xFF;  // 提取红色通道
    uint8_t g = (color >> 8) & 0xFF;   // 提取绿色通道
    uint8_t b = color & 0xFF;          // 提取蓝色通道

    uint16_t red = (r >> 3) & 0x1F;    // 将红色通道转换为5位
    uint16_t green = (g >> 2) & 0x3F;  // 将绿色通道转换为6位
    uint16_t blue = (b >> 3) & 0x1F;   // 将蓝色通道转换为5位
    
    return (red << 11) | (green << 5) | blue;  // 组合成RGB565格式的颜色值
}

//ui背景框图
void UI_Background()
{
    uint8_t i,j;
    
    //标题显示 黑色显示
    BACK_COLOR = WHITE;
    POINT_COLOR = BLACK;
    
    //LCD_Fill(Sheet_x-26, Sheet_y-72, Sheet_x-6, Sheet_y-5, BLACK);	// 左上角矩形，现用作工业屏接入指示
    LCD_ShowString(Sheet_x+36, Sheet_y-70, 24*3, 24, 24, "HX6203");
    LCD_Fill(Sheet_x+4, Sheet_y-40, Sheet_x+136, Sheet_y-38, BLACK);
    LCD_ShowString(Sheet_x+4, Sheet_y-32, 24*6, 24, 24, (u8 *)__DATE__);
	
    //柱状图表格绘制，红色显示
    POINT_COLOR = RED;
    for(i=0; i<17; i++)
    {   
        //表格竖线 10条 正反功率
        if(i<10)
        {
            LCD_DrawLine( Sheet_x+i*81, Sheet_y, Sheet_x+i*81, Sheet_y+320);
            if(i<9)
            {
                LCD_ShowString(Sheet_x+5+i*81, Sheet_y+283, 16*5, 16, 16, "P-:     W");
                LCD_ShowString(Sheet_x+5+i*81, Sheet_y+300, 16*5, 16, 16, "P+:     W");
            }
        }
            //表格横线  5条
        if(i==0 || i==2 || i==8 || i==14 || i==16)  LCD_DrawLine( Sheet_x, Sheet_y+i*20, Sheet_x+728, Sheet_y+i*20);
        if(i>2 && i<14 && i!=8) 
        {
            for(j=0; j<28; j++)
            {   //表格刻度线 
                LCD_DrawLine( Sheet_x-2+j*27, Sheet_y+i*20, Sheet_x+2+j*27, Sheet_y+i*20);
            }
            
        }
        
    }
    
    //电流 温度 符号/单位，红色显示
    LCD_ShowString(Sheet_x-26, Sheet_y+12, 16*3, 16, 16, "I/A");
    LCD_ShowString(Sheet_x+732, Sheet_y+12, 16*3, 16, 16, "I/A");
    
    LCD_ShowString(Sheet_x-33, Sheet_y+290, 16*3, 16, 16, "T/^C");
    LCD_ShowString(Sheet_x+732, Sheet_y+290, 16*3, 16, 16, "T/^C");
    
    //电流 温度两端刻度值，黑色显示
    POINT_COLOR = BLACK;
    for(i=0; i<5; i++)  //电流刻度值
    {
        LCD_ShowNum(Sheet_x-20, Sheet_y+52+i*20, 10-i*2, 2, 16);
        LCD_ShowNum(Sheet_x+732, Sheet_y+52+i*20, 10-i*2, 2, 16);
    }
		for(i=0; i<5; i++)  //温度刻度值
    {
        LCD_ShowNum(Sheet_x-30, Sheet_y+172+i*20, 100-i*20, 3, 16);
        LCD_ShowNum(Sheet_x+732, Sheet_y+172+i*20, 100-i*20, 3, 16);
    }
    
    //种子源及输出状态矩形框100*60，黑色显示
    //两路DA状态矩形框
    LCD_DrawRectangle(Sheet_x+194, Sheet_y-70, Sheet_x+294, Sheet_y-10);
    LCD_ShowString(Sheet_x+265, Sheet_y-57, 24*1, 24, 24, ".");
    LCD_ShowString(Sheet_x+233, Sheet_y-36, 24*2, 24, 24, ".  C");
    LCD_ShowString(Sheet_x+233, Sheet_y-67, 24*2, 24, 24, ".  A");
    
    LCD_DrawRectangle(Sheet_x+434, Sheet_y-70, Sheet_x+534, Sheet_y-10);
    
    LCD_ShowString(Sheet_x+505, Sheet_y-57, 24*1, 24, 24, ".");
    LCD_ShowString(Sheet_x+473, Sheet_y-36, 24*2, 24, 24, ".  C");
    LCD_ShowString(Sheet_x+473, Sheet_y-67, 24*2, 24, 24, ".  A");
    
    
    //合路矩形框
    LCD_DrawRectangle(Sheet_x+294, Sheet_y-55, Sheet_x+434, Sheet_y-25);
    //向下输出箭头
//    LCD_DrawLine(Sheet_x+364, Sheet_y-2, Sheet_x+341, Sheet_y-25);
//    LCD_DrawLine(Sheet_x+364, Sheet_y-2, Sheet_x+387, Sheet_y-25);
    
    //种子源矩形框
    LCD_DrawRectangle(Sheet_x+567, Sheet_y-70, Sheet_x+729, Sheet_y-10);
    LCD_DrawLine(Sheet_x+567, Sheet_y-50, Sheet_x+729, Sheet_y-50);
    LCD_DrawLine(Sheet_x+648, Sheet_y-50, Sheet_x+648, Sheet_y-10);
    
    LCD_ShowString(Sheet_x+605, Sheet_y-69, 16*6, 16, 16, "SEED SOURCE");
    LCD_ShowString(Sheet_x+598, Sheet_y-43, 24*2, 24, 24, ".  V");
    LCD_ShowString(Sheet_x+679, Sheet_y-43, 24*2, 24, 24, ".  A");
    
    //种子源箭头
    LCD_DrawLine(Sheet_x+537, Sheet_y-40, Sheet_x+567, Sheet_y-10);
    LCD_DrawLine(Sheet_x+537, Sheet_y-40, Sheet_x+567, Sheet_y-70);
    //*暂时在ui刷新中调用
    for(i=0; i<9; i++)
    {
        //九路输出箭头
        LCD_DrawLine(Sheet_x+40+i*81, Sheet_y+344, Sheet_x+17+i*81, Sheet_y+321);
        LCD_DrawLine(Sheet_x+40+i*81, Sheet_y+344, Sheet_x+63+i*81, Sheet_y+321);
        //刀片序号
        LCD_ShowNum(Sheet_x+37+i*81, Sheet_y+321, i+1, 1, 16);
    }
    
    //合路横线
    LCD_DrawLine(Sheet_x+39, Sheet_y+344, Sheet_x+689, Sheet_y+344);
    
    //总功率输出框
    LCD_DrawLine( Sheet_x+304, Sheet_y+345, Sheet_x+304, Sheet_y+399);
    LCD_DrawLine( Sheet_x+425, Sheet_y+345, Sheet_x+425, Sheet_y+399);
    LCD_ShowString(Sheet_x+342, Sheet_y+351, 16*3, 16, 16, "OUTPUT");
    LCD_ShowString(Sheet_x+400, Sheet_y+375, 16*1, 16, 16, "W");
    
    //设定功率与反向功率状态框 121*45
    LCD_DrawRectangle(Sheet_x+162, Sheet_y+350, Sheet_x+283, Sheet_y+395);
    LCD_ShowString(Sheet_x+171, Sheet_y+351, 16*7, 16, 16, "REVERSE POWER");
    LCD_ShowString(Sheet_x+258, Sheet_y+375, 16*1, 16, 16, "W");
    LCD_DrawRectangle(Sheet_x+445, Sheet_y+350, Sheet_x+566, Sheet_y+395);
    LCD_ShowString(Sheet_x+470, Sheet_y+351, 16*5, 16, 16, "SET POWER");
    LCD_ShowString(Sheet_x+540, Sheet_y+375, 16*1, 16, 16, "W");
    
    //错误计数及错误代码 红色背景 白色显示，信息内容为白色背景 红色显示
    BACK_COLOR = RED;
    POINT_COLOR = WHITE;
    //(sx,sy),(ex,ey):填充矩形对角坐标,区域大小为:(ex-sx+1)*(ey-sy+1)
    LCD_Fill(Sheet_x-29, Sheet_y+358, Sheet_x+52, Sheet_y+390, RED);
    LCD_ShowString(Sheet_x-27, Sheet_y+358, 16*5, 16, 16, "Err code:");
    
//    LCD_ShowString(Sheet_x-27, Sheet_y+374, 16*5, 16, 16, "ERR code :");
    
//    BACK_COLOR = WHITE;
//    POINT_COLOR = RED;
//    char* str = HexToString(0);
//    LCD_ShowString(Sheet_x+55, Sheet_y+374, 16*1, 16, 16, "0x");
//    LCD_ShowString(Sheet_x+55, Sheet_y+374, 16*2, 16, 16, (u8*)str);
//    free(str);
    
    //运行计时 蓝色背景 白色显示
    BACK_COLOR = BLUE;
//    POINT_COLOR = WHITE;
    LCD_Fill(Sheet_x+674, Sheet_y+358, Sheet_x+756, Sheet_y+390, BLUE);
    LCD_ShowString(Sheet_x+676, Sheet_y+358, 16*5, 16, 16, "Run time :");
}


///*种子源，两路前级PA及九路刀片使能状态刷新(根据系统状态 黑色关机 蓝色开机)
void SW_State_Refresh()
{
    uint8_t i,j;
    
    POINT_COLOR = WHITE;
	
	if(HX6203.ControlBit)	// 当连接工业屏时矩形变成蓝色，否则呈黑色
		LCD_Fill(Sheet_x-26, Sheet_y-72, Sheet_x-6, Sheet_y-5, BLUE);
	else
		LCD_Fill(Sheet_x-26, Sheet_y-72, Sheet_x-6, Sheet_y-5, BLACK);
    
    //遍历所有单元使能
    for(i=0; i<11; i++)
    {   
        if(i < 9) //九路刀片使能
        {
             if(BIT_READ(HX6203.AMP_STA, i))
            {
                BACK_COLOR = BLACK;

                for(j=0; j<23; j++)
                {
                    LCD_Fill((Sheet_x+18+j)+i*81, Sheet_y+321+j, (Sheet_x+62-j)+i*81, Sheet_y+321+j, BLACK);
                }
                LCD_ShowNum(Sheet_x+37+i*81, Sheet_y+321, i+1, 1, 16);
                
            }
            else
            {
                BACK_COLOR = BLUE;
                for(j=0; j<23; j++)
                {
                    LCD_Fill((Sheet_x+18+j)+i*81, Sheet_y+321+j, (Sheet_x+62-j)+i*81, Sheet_y+321+j, BLUE);
                }
                LCD_ShowNum(Sheet_x+37+i*81, Sheet_y+321, i+1, 1, 16);
            }
        }
        else if(i == 9)
        {
            if(HX6203.Preamp[0].PD & HX6203.Preamp[1].PD)   //前级PA输出使能
            {
                for(j=0; j<23;j++)
                {
                    LCD_Fill(Sheet_x+342+j, Sheet_y-24+j, Sheet_x+386-j, Sheet_y-24+j, BLUE);
                }
            }
            else
            {
                for(j=0; j<23; j++)
                {
                    LCD_Fill(Sheet_x+342+j, Sheet_y-24+j, Sheet_x+386-j, Sheet_y-24+j, BLACK);
                }
            }
        }
        else if(i == 10)
        {
            if(Seed.PD)   //种子源输出使能
            {
                for(j=0; j<29; j++)
                {
                    LCD_Fill((Sheet_x+538+j), Sheet_y-40-j, Sheet_x+538+j, Sheet_y-40+j, BLUE);
                }
            }
            else 
            {
                for(j=0; j<29; j++)
                {
                    LCD_Fill((Sheet_x+538+j), Sheet_y-40-j, Sheet_x+538+j, Sheet_y-40+j, BLACK);
                }
            }
        }
    }
}


/*
错误信息刷新

无返回 调用一次刷新一次
*/
void Err_msg_Refresh()
{
    uint8_t i;
    
    //遍历九路刀片及两路前级PA错误信息
    for(i=0; i<11; i++)
    {
        if(i<9) //九路刀片
        {   
            if(NodeState[i])  //色块刷新 红色错误，绿色正常
            {
                LCD_Fill(Sheet_x+5+i*81, Sheet_y+4, Sheet_x+76+i*81, Sheet_y+19, RED);
            } else {
                LCD_Fill(Sheet_x+5+i*81, Sheet_y+4, Sheet_x+76+i*81, Sheet_y+19, GREEN);
            }
            
        } else {
            if(NodeState[i]) //两路前级PA 色块刷新
            {
                LCD_Fill(Sheet_x+296+(i-9)*69, Sheet_y-53, Sheet_x+363+(i-9)*69, Sheet_y-43, RED);
            } else {
                LCD_Fill(Sheet_x+296+(i-9)*69, Sheet_y-53, Sheet_x+363+(i-9)*69, Sheet_y-43, GREEN);
            }
        }
    }
    BACK_COLOR = WHITE;
    POINT_COLOR = RED;
    if(HX6203_Protect)
    {
        if(BIT_READ(HX6203_Protect, PA250TempProtectBit))
        {
            LCD_ShowString(Sheet_x+75, Sheet_y+358, 16*10, 16, 16, "PA modue");
            LCD_ShowString(Sheet_x+59, Sheet_y+374, 16*10, 16, 16, "High temp!!!");
        }
        else if(BIT_READ(HX6203_Protect, PA250CurrProtectBit))
        {
            LCD_ShowString(Sheet_x+75, Sheet_y+358, 16*10, 16, 16, "PA modue");
            LCD_ShowString(Sheet_x+60, Sheet_y+374, 16*10, 16, 16, "CurrAbnormal");
        }
        else if(BIT_READ(HX6203_Protect, AMPTempProtectBit))
        {
            LCD_ShowString(Sheet_x+95, Sheet_y+358, 16*10, 16, 16, "AMP");
            LCD_ShowString(Sheet_x+59, Sheet_y+374, 16*10, 16, 16, "High temp!!!");
        }
        else if(BIT_READ(HX6203_Protect, AMPCurrProtectBit))
        {
            LCD_ShowString(Sheet_x+95, Sheet_y+358, 16*10, 16, 16, "AMP");
            LCD_ShowString(Sheet_x+60, Sheet_y+374, 16*10, 16, 16, "CurrAbnormal");
        }
        else if(BIT_READ(HX6203_Protect, AMPReflectProtectBit))
        {
            LCD_ShowString(Sheet_x+59, Sheet_y+358, 16*10, 16, 16, "AMP reflect");
            LCD_ShowString(Sheet_x+71, Sheet_y+374, 16*10, 16, 16, "Excessive");
        }
        else if(BIT_READ(HX6203_Protect, AMPRfBalanceProtectBit))
        {
            LCD_ShowString(Sheet_x+84, Sheet_y+358, 16*10, 16, 16, "AMP RF");
            LCD_ShowString(Sheet_x+71, Sheet_y+374, 16*10, 16, 16, "Imbalance");
        }
        else if(BIT_READ(HX6203_Protect, HX6203ReflectProtectBit))
        {
            LCD_ShowString(Sheet_x+84, Sheet_y+358, 16*10, 16, 16, "HX6203");
            LCD_ShowString(Sheet_x+71, Sheet_y+374, 16*10, 16, 16, "Excessive");
        }
        else if(BIT_READ(HX6203_Protect, HX6203GainProtectBit))
        {
            LCD_ShowString(Sheet_x+84, Sheet_y+358, 16*10, 16, 16, "HX6203");
            LCD_ShowString(Sheet_x+61, Sheet_y+374, 16*10, 16, 16, "GainAbnormal");
        }
    }
    else
    {
        LCD_Fill(Sheet_x+58, Sheet_y+358, Sheet_x+156, Sheet_y+390, WHITE);
    }
    
    BACK_COLOR = RED;
    POINT_COLOR = WHITE;
    
    sprintf(Err_Str, "%04x", HX6203_Protect);
    LCD_ShowString(Sheet_x-27, Sheet_y+374, 16*3, 16, 16, (u8*)Err_Str);
    
    while(ERROR_HAPPEN && PROTECT_FLAG)   //如果触发保护，则左下角显示错误代码，白色背景，红色显示，并锁定状态
    {
        Extern_UART_GetData();  //检测外部通讯
        
        //错误信息板开始闪烁提示
        BACK_COLOR = WHITE;
        POINT_COLOR = RED;
        LCD_Fill(Sheet_x-29, Sheet_y+358, Sheet_x+52, Sheet_y+390, WHITE);
        LCD_ShowString(Sheet_x-27, Sheet_y+358, 16*5, 16, 16, "Err code:");
        LCD_ShowString(Sheet_x-27, Sheet_y+374, 16*3, 16, 16, (u8*)Err_Str);
        delay_ms(250);
        
        BACK_COLOR = RED;
        POINT_COLOR = WHITE;
        LCD_Fill(Sheet_x-29, Sheet_y+358, Sheet_x+52, Sheet_y+390, RED);
        LCD_ShowString(Sheet_x-27, Sheet_y+358, 16*5, 16, 16, "Err code:");
        LCD_ShowString(Sheet_x-27, Sheet_y+374, 16*3, 16, 16, (u8*)Err_Str);
        delay_ms(250);
    }
}
//随机数
//void Rand_Num()
//{
//    uint8_t i,j;
//    for(i=0; i<9; i++)
//    {
//        for(j=0; j<3; j++)
//        {
//            HX6203.AMP[i].PA[j].Curr = (float)(rand()%120);
//            HX6203.AMP[i].PA[j].Temp = (float)((rand()%90*120.0/90.0));
//        }
//    }
//    
//}

//图表刷新
void Chart_Refresh()
{
    static uint16_t colour;
    
    for(uint8_t i=0; i<9; i++)
    {
        for(uint8_t j=0; j<3; j++)  //电流直方图
        {
            LCD_Fill(Sheet_x+3+j*27+i*81, Sheet_y+41, Sheet_x+24+j*27+i*81, Sheet_y+159-HX6203.AMP[i].PA[j].Curr*10, WHITE);//上限41，下限159
            
            LCD_Fill(Sheet_x+3+j*27+i*81, Sheet_y+41+(Show_MAX-HX6203.AMP[i].PA[j].Curr*10), Sheet_x+24+j*27+i*81, Sheet_y+159, GREEN);//上限41，下限159
        }
        for(uint8_t j=0; j<3; j++)  //温度直方图
        {
            LCD_Fill(Sheet_x+3+j*27+i*81, Sheet_y+161, Sheet_x+24+j*27+i*81, Sheet_y+279-(int)HX6203.AMP[i].PA[j].Temp%120, WHITE);//上限161，下限279
            
            if(HX6203.AMP[i].PA[j].Temp > WARNING_TempValue)    //大于警告温度为橙色
            {
                colour = ORANGE;
                if(HX6203.AMP[i].PA[j].Temp > DANGER_TempValue) //大于危险温度为红色
                    colour = RED;
            }
            else    //否则为绿色
                colour = GREEN;
            LCD_Fill(Sheet_x+3+j*27+i*81, Sheet_y+161+(Show_MAX-(int)HX6203.AMP[i].PA[j].Temp%120), Sheet_x+24+j*27+i*81, Sheet_y+279, colour);//上限161，下限279
        }
    }
}

//取小数点之后两位的数
int After_Point(float num)
{
    int before = num;
    float after  = num - before;
    before = (float)(after*10);
    return before;
}

//数据刷新 蓝色显示
void Data_Refresh()
{
    uint8_t i,j;
    
    BACK_COLOR = WHITE;
    
	if(HX6203.SetCountdown > -1)
	{
		if(!KEY3)	POINT_COLOR = BLUE;
		if(!KEY4)	POINT_COLOR = RED;
		LCD_ShowNum(Sheet_x+160, Sheet_y-51, HX6203.SetCountdown, 1, 24);
	}
	else
	{
		LCD_Fill(Sheet_x+160, Sheet_y-51, Sheet_x+180, Sheet_y-31, WHITE);
	}
	
	POINT_COLOR = BLUE;
    
    //种子源 电压 电流                  参数
    LCD_ShowNum(Sheet_x+574, Sheet_y-43, (int)Seed.Vbias, 2, 24);//V
    LCD_ShowNum(Sheet_x+606, Sheet_y-43, After_Point(Seed.Vbias), 1, 24);//V
    
    LCD_ShowNum(Sheet_x+655, Sheet_y-43, (int)Seed.Curr, 2, 24);//I
    LCD_ShowNum(Sheet_x+687, Sheet_y-43, After_Point(Seed.Curr), 1, 24);//I
    
    //两路前级PA 电流 温度
    LCD_ShowNum(Sheet_x+208, Sheet_y-67, (int)HX6203.Preamp[0].Curr, 2, 24);//A
    LCD_ShowNum(Sheet_x+240, Sheet_y-67, After_Point(HX6203.Preamp[0].Curr), 1, 24);//A
    
    LCD_ShowNum(Sheet_x+208, Sheet_y-36, (int)HX6203.Preamp[0].Temp, 2, 24);//C
    LCD_ShowNum(Sheet_x+240, Sheet_y-36, After_Point(HX6203.Preamp[0].Temp), 1, 24);//C
    
    LCD_ShowNum(Sheet_x+448, Sheet_y-67, (int)HX6203.Preamp[1].Curr, 2, 24);//A
    LCD_ShowNum(Sheet_x+480, Sheet_y-67, After_Point(HX6203.Preamp[1].Curr), 1, 24);//A
    
    LCD_ShowNum(Sheet_x+448, Sheet_y-36, (int)HX6203.Preamp[1].Temp, 2, 24);//C
    LCD_ShowNum(Sheet_x+480, Sheet_y-36, After_Point(HX6203.Preamp[1].Temp), 1, 24);//C
    
    //九路刀片负压 正反向功率
    for(i=0; i<9; i++)
    {
        for(j=0; j<3; j++)
        {
            LCD_ShowNum(Sheet_x+4+i*81+j*27, Sheet_y+22, (int)(-1*HX6203.AMP[i].PA[j].Vbias), 1, 16);
            LCD_ShowString(Sheet_x+11+i*81+j*27, Sheet_y+22, 16*1, 16, 16, ".");
            LCD_ShowNum(Sheet_x+16+i*81+j*27, Sheet_y+22, (int)((HX6203.AMP[i].PA[j].Vbias-(int)(HX6203.AMP[i].PA[j].Vbias))*(-10.0)), 1, 16);
					
        }
        LCD_ShowNum(Sheet_x+31+i*81, Sheet_y+283, (int)HX6203.AMP[i].RevRF, 4, 16);//P-
        LCD_ShowNum(Sheet_x+31+i*81, Sheet_y+300, (int)HX6203.AMP[i].FwdRF, 4, 16);//P+
    }

    //输出功率
    LCD_ShowNum(Sheet_x+337, Sheet_y+368, (int)HX6203.FwdRF, 4, 24);
    //反向功率
    LCD_ShowNum(Sheet_x+195, Sheet_y+368, (int)HX6203.RevRF, 4, 24);
    //当前设定的功率
	LCD_ShowNum(Sheet_x+600, Sheet_y+368, PowerSetValue, 4, 24);
	
//	if((RunTime.s % 10) == 0)	//显示保护阈值
//	{
//		LCD_ShowNum(Sheet_x+580, Sheet_y+350, abs((int)HX6203.EEPROMdata.ampGateVoltage), 4, 12);
//		LCD_ShowNum(Sheet_x+620, Sheet_y+350, HX6203.EEPROMdata.pProtect, 4, 12);
//	}
	
    //设定功率 当动作计数不为-1时且到达设定功率以蓝色显示，否则黑色显示
    if((ACT_Count==-1) && (P_Complete==1))  POINT_COLOR = BLACK;
    LCD_ShowNum(Sheet_x+480, Sheet_y+368, (int)HX6203.AimRF, 4, 24);
}

void HX6203_UI_Init()
{       
    Err_Str = malloc(10);  // 分配内存空间来存储错误信息转换后的字符串
    Time_Str = malloc(15);

    LCD_Clear(WHITE);	//清屏
    UI_Background();
}

void RunTime_Refresh()
{
    BACK_COLOR = BLUE;
    POINT_COLOR = WHITE;
    
    sprintf(Time_Str, "%4d:%02d:%02d", RunTime.h, RunTime.m, RunTime.s);
    LCD_ShowString(Sheet_x+676, Sheet_y+374, 16*8, 16, 16, (u8*)Time_Str);
}

void Refresh_UI()
{   
    SW_State_Refresh();
    Err_msg_Refresh();
    Chart_Refresh();
    Data_Refresh();
    RunTime_Refresh();
}
